<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="user-form">
                    <div class="select-list">
                        <ul>
                            <li>
                                订单编号：<input type="text" name="orderId"/>
                            </li>
                            <li class="select-time">
                                <label>创建时间： </label>
                                <input type="text" class="time-input" name="params[beginTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" name="params[endTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" data-mobile-responsive="true"></table>
            </div>
        </div>
    </div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var prefix = ctx + "system/userOrder";

        var datas = [[${@dict.getType('sys_order_status')}]];

        $(function() {
            var options = {
                url: prefix + "/list?status=4",
                updateUrl: prefix + "/edit/{id}",
                detailUrl: prefix + "/detail/{id}",
                queryParams:{
                    status:"4"
                },
                search: false,
                showSearch:false,
                showRefresh:false,
                showColumns:false,
                showToggle:false,
                showExport:false,
                modalName: "订单列",
                columns: [{
		            checkbox: true
		        },
				{
					field : 'orderId', 
					title : '订单编号'
				},
				{
					field : 'status', 
					title : '状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
				},
				{
					field : 'createTime', 
					title : '下单时间'
				},

				{
					field : 'totalPrice', 
					title : '总价'
				},
				{
					field : 'receiveAddr', 
					title : '收货地址'
				},
				{
					field : 'receiveUser', 
					title : '收货人'
				},
				{
					field : 'receiveTel', 
					title : '收货电话'
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
                        actions.push('<a class="btn btn-link btn-sm" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.orderId + '\')"><i class="fa fa-eye"></i>查看</a> ');
                        if(row.status == 6){
                            actions.push('<a class="btn btn-link btn-sm" href="javascript:void(0)" onclick="handleRefund(\'' + row.orderId + '\')"><i class="fa fa-edit"></i>处理</a> ');
                        }
                        if(row.status == 4){
                            actions.push('<a class="btn btn-link btn-sm" href="javascript:void(0)" onclick="sendGoods(\'' + row.orderId + '\')"><i class="fa fa-edit"></i>配送</a> ');
                        }
                        return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });

        function sendGoods(orderId) {
            $.operate.edit(orderId,'','',['发货','关闭']);
        }

        function handleRefund(orderId) {
            $.modal.open("处理退款",ctx+"user/userOrder/handleRefund?orderId="+orderId,800,400);
        }
    </script>
</body>
</html>